﻿using System.Web.Mvc;

namespace TheDFFL.Web.Controllers
{
    public class TestController : BaseController
    {
        public ActionResult LogOn()
        {
            return View();
        }

        [HttpPost]
        public void Validate()
        {
            var consumer = base.CreateConsumer();
            var response = consumer.PrepareRequestUserAuthorization();
            consumer.Channel.Send(response);
        }

        public ActionResult Validate(string oauth_token, string oauth_verifier)
        {
            if (Session["WcfTokenManager"] != null)
            {
                var consumer = base.CreateConsumer();
                var accessTokenMessage = consumer.ProcessUserAuthorization();
                if (accessTokenMessage != null)
                {
                    Session["WcfAccessToken"] = accessTokenMessage.AccessToken;
                }
            }

            return RedirectToAction("Index", "Home");
        }
    }
}
